package com.ypinkj.app.api;


import com.ypinkj.app.entity.Feedback;
import com.ypinkj.app.mapper.FeedbackMapper;
import com.ypinkj.app.utils.resultutils.Result;
import com.ypinkj.app.utils.resultutils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LF
 * @since 2020-10-19
 */
@Api(tags = "意见反馈")
@RestController
@RequestMapping("/feedback")
public class FeedbackController {

    @Autowired
    FeedbackMapper feedbackMapper;

    @ApiOperation("保存")
    @PutMapping
    public Result save(@RequestBody Feedback feedback){
        int i = feedbackMapper.insert(feedback);
        return i>0 ? ResultUtil.success() : ResultUtil.errorMsg();
    }

    @ApiOperation("列表")
    @GetMapping
    public Result getList(){
        List<Feedback> list = feedbackMapper.selectList(null);
        return list.size()>0 ? ResultUtil.success(list) : ResultUtil.errorMsg();
    }
}
